package 富婆梦.第一阶段.Java基础视频学习.线程的练习.练习;

import java.util.concurrent.*;

/**
 * @ProjectName: java-learning
 * @Package: 富婆梦.第一阶段.线程的练习.练习
 * @ClassName: Demo4
 * @Author: hemengjin
 * @Description:
 * @Date:2021/11/1 19:51
 * @Version: 1.0
 */
public class Demo4 implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        return 100;
    }

    public static void main(String[] args) {
        //创建一个线程池，线程池有两个线程
        ExecutorService es = Executors.newFixedThreadPool(2);
        Future<Integer> f = es.submit(new Demo4());
        try {
            Integer i = f.get();
            System.out.println(i);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
}
